package cn.schoolwow.workflow.module.task.action.flow.complete.nodeType.general;

import cn.schoolwow.quickflow.domain.FlowContext;
import cn.schoolwow.quickflow.flow.BusinessFlow;
import cn.schoolwow.workflow.module.common.flow.AddWorkFlowHistoryFlow;
import cn.schoolwow.workflow.module.instance.action.flow.start.ExecuteAfterInstanceFinishListenerFlow;
import cn.schoolwow.workflow.module.task.action.domain.CompleteTaskOption;

public class HandleEndNodeFlow implements BusinessFlow {
    @Override
    public void executeBusinessFlow(FlowContext flowContext) throws Exception {
        CompleteTaskOption completeTaskOption = flowContext.checkInstanceData(CompleteTaskOption.class);

        flowContext.executeFlowList(new ExecuteAfterInstanceFinishListenerFlow());
        completeTaskOption.instanceFinished = true;

        flowContext.startFlow(new AddWorkFlowHistoryFlow())
                .putCurrentCompositeFlowData("message", "工作流实例已结束")
                .execute();
    }

    @Override
    public String name() {
        return "处理结束节点";
    }
}
